
class LocalVarDecl extends Statement {
	
	DataInfo dataInfo;
	
	private String varType;
	private String varName;
	
	public LocalVarDecl(String type, String name, DataInfo dataInfo){
		
		varType = type;
		varName = name;
		
		this.dataInfo = dataInfo;
		
	}
	
	public String toString(){
		
		return("localVarDecl "+varName+" \n");
		
	}
	
	public void check() throws SemanticException {
		
		SymbolTable st = SymbolTable.getInstance();
		
		if(st.contains(varName))
		{
			String details = "The identifier "+varName+" is already defined.";
			if( dataInfo != null )
				throw new SemanticException( dataInfo.lineNumber, dataInfo.charNumber, dataInfo.line, details );
			else
				throw new SemanticException( details );
		}
			
		
		st.add(new Entry(varName, "Variable", varType));
		
	}

}
